package org.gdpu.Service.Impl;

import org.gdpu.Service.CampusService;
import org.gdpu.base.DaoSupport;
import org.gdpu.model.Campus;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.persistence.Query;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by HEWI2 on 2/17/14.
 */

@Service
@Transactional
public class CampusServiceImpl extends DaoSupport<Campus> implements CampusService {


    @Override
    public Campus findByCampusByName(String campus) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("campusName", campus);
        return (Campus) this.findSpecialObject(Campus.class, params);
    }

    @Override
    public List<Campus> findAll() {
        Query query = em.createQuery("from Campus p");
        return query.getResultList();
    }
}
